;;; RLlib copyright 2010 Adam White (theroguemonkey@gmail.com)
;;;; Licensed under GNU General Public Licence v2 or later - refer COPYING

(in-package #:rllib)

;;;============================================================================
;;; BMP
;;;============================================================================

(cffi:defcfun ("SDL_SaveBMP_RW" %sdl-save-bmp-rw) :int
  (surface :pointer)
  (dst :pointer)
  (freedst :int))

(cffi:defcfun ("SDL_LoadBMP_RW" %sdl-load-bmp-rw) %sdl-surface
  (src :pointer)
  (freesrc :int))

(defun sdl-save-bmp (surface file)
  (%sdl-save-bmp-rw surface (%sdl-rw-from-file file "wb") 1))

(defun sdl-load-bmp (file)
  (%sdl-load-bmp-rw (%sdl-rw-from-file file "rb") 1))

;;;============================================================================
;;; Image
;;;============================================================================

(cffi:defbitfield img-init-flags
  (:init-jpg #x01)
  (:init-png #x02)
  (:init-tif #x04))

(cffi:defcfun ("IMG_Init" img-init) img-init-flags
  (flags img-init-flags))

(cffi:defcfun ("IMG_Quit" img-quit) :void)

(cffi:defcfun ("IMG_Load" img-load) %sdl-surface
  (file :string))

